home *** CD-ROM | disk | FTP | other *** search
- /* puttext.c --- p 890 --- */
- #include <alloc.h>
- #include <conio.h>
- main()
- {
- int i, bufsize, top = 1, left = 1, right = 80, bottom = 5;
- char *tbuffer;
- clrscr();
- gotoxy(1, 1);
- for(i = 1 ; i <= bottom; i++)
- cprintf("Press any key to save and restore these long lines"
- " of text in a narrow column\n\r");
- /* Now use gettext to save
- this text in a buffer */
- bufsize = 2 * (bottom - top + 1) * (right - left + 1);
- if((tbuffer = (char *) malloc(bufsize)) == NULL)
- {
- cputs("Error allocating buffer!");
- exit(1);
- }
- if(!gettext(left, top, right, bottom, tbuffer))
- {
- cputs("Error saving text!");
- exit(1);
- }
- getch(); /* wait for a keypress */
- /* Restore buffer using puttext
- in a narrow box */
- if(!puttext(left, top + 11, right / 2, bottom * 2 + 11, tbuffer))
- cputs("Error restoring text!");
- getch();
- }